package cate.common.table.activity.foodhunter.sheet;

import cate.common.table.ESheet;
import cate.common.table.activity.foodhunter.row.FoodHunterTaskRow;
import cate.common.table.guild.task.GuildTaskWeightRow;
import cate.common.util.random.RWList;

import java.util.*;
import java.util.stream.Collectors;

public class FoodHunterTaskSheet extends ESheet<FoodHunterTaskRow> {
    @Override
    public String getSheetName() {
        return "任务";
    }

    public Map<Integer, List<FoodHunterTaskRow>> groupMap;

    public void onLoaded() {
        groupMap = this.list.stream().collect(Collectors.groupingBy(row -> row.group));
    }

    public FoodHunterTaskRow getRowByTaskId(int taskId) {
        Optional<FoodHunterTaskRow> first = this.list.stream().filter(row->row.taskId==taskId).findFirst();
        return first.orElse(null);
    }

    public FoodHunterTaskRow getRowByGroupAndTaskId(int group, int taskId) {
        List<FoodHunterTaskRow> rows = groupMap.get(group);
        for (FoodHunterTaskRow row : rows) {
            if (row.taskId == taskId) {
                return row;
            }
        }
        return null;
    }

    public List<FoodHunterTaskRow> getRowListByDay(int day) {
        return groupMap.get(day);
    }
}
